package com.example.easyscript.service.task;

import cn.hutool.extra.cglib.CglibUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.easyscript.bean.task.TaskBean;
import com.example.easyscript.common.page.Page;
import com.example.easyscript.entity.task.Task;
import com.example.easyscript.mapper.TaskMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author huzixian
 * @date 2023-03-08
 */
@Slf4j
@Service
public class TaskService  extends ServiceImpl<TaskMapper, Task> {

    public TaskBean getTaskBeanById(Integer taskId) {
        Task task = baseMapper.selectById(taskId);
        TaskBean taskBean = CglibUtil.copy(task, TaskBean.class);
        return taskBean;
    }

    public Page<List<Task>> getPage(Page page) {
        page.setRecords(baseMapper.selectList(new QueryWrapper<>()));
        return page;
    }
}
